<template>
  <div class="banxin">
    <div class="top">
      <div class="nva">
        <div class="center">
          <div>
            <img
              src="https://m.cdfgsanya.com/wap/resources/images/icons/icon-search@2x.444b6495.png"
              alt=""
            />
            <input type="text" placeholder="兰蔻" @click="fun()"/>
          </div>
        </div>
        <div class="right">
          <img
            src="https://m.cdfgsanya.com/wap/resources/images/icons/icon-customer-service@2x.dfee9fd8.png"
            alt=""
          />
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="banner2">
        <van-swipe :autoplay="3000" :width="370" :height="156">
          <van-swipe-item v-for="(image, index) in images" :key="index">
            <img v-lazy="image" />
          </van-swipe-item>
        </van-swipe>
      </div>
    </div>
  </div>
</template>

<script>
import service from "../../../../src/utils/service";
import Vue from "vue";
import { Lazyload } from "vant";

Vue.use(Lazyload);
export default {
  methods:{
fun(){
  this.$router.push("/search");
}
  },
     data() {
    return {
      images: [],
  
    };
  },
  mounted() {
    service({
      url: "  http://localhost:3000/banner",
      method: "get",
    }).then((res) => {
      res.data.forEach((element) => {
        console.log(element);
        this.images.push(element.img);
      });
    });
  },
};
</script>

<style scoped>
.banxin {
  background-image: url(https://pic.cdfgsanya.com/assets/upload/visual/7203063f8d2b65e1d0ba2787e02fd849.png);
  height: 212px;
}
.nva {
  display: flex;
  width: 375px;
  height: 40px;
  background-color: #e7e5ef;
  /* position: sticky;
  top: 0; */
  /* z-index: 3; */
}
.top .center input {
  border: white;
  margin-left: 8px;
  height: 31px;
  text-align: center;
  margin-top: 0;
   position: absolute;
  top: 0; 
}

.nva .center {
  width: 310px;
  height: 32px;
  background-color: #fff;
  margin: 4px 10px 4px 7px;
  border-radius: 1rem;
  position: relative;
}
.nva .center img {
  width: 17px;
  height: 17px;
  margin: 7px 10px;
}
.nva .right img {
  width: 22px;
  height: 22px;
  margin: 9px 8px;
}
/* .big {
  display: flex;
  background-color: #f8f6f6;
} */

.banner2 {
  width: 352px;
  height: 156px;
  margin: 10px;
  border-radius: 10px 20px;
  border-radius: 5px;

}
.van-swipe-item img {
  width: 353px;
  height: 156px;
  border-radius: 5px;
}
</style>